package com.example.apiproject.entity.form;

import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.datetime.joda.LocalDateTimeParser;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
@Data
public class AddActivityForm {


    /**
     * 标题
     */
    @Length(max = 20, message = "标题不能超过20个字符")
    @NotBlank(message = "参数有误")
    private String title;
    /**
     * 内容
     */
    @Length(max = 500, message = "内容不能超过400个字符")
    @NotBlank(message = "参数有误")
    private String content;
    /**
     * 文件
     */
    private List<String> media;

    /**
     * 帖子类型：1 图文 ，2视频 ，3文章，4投票
     */

    /**
     * 地址名称
     */
    private String address;



    private LocalDateTime startTime;
    private LocalDateTime endTime;
    private Integer value;
    private String sname;
    private String sidentyNumber;
    private String sphone;
    private int type;

    public void setStartTime(String startTime) {
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        LocalDateTime LocalTime = LocalDateTime.parse(startTime,df);
        this.startTime = LocalTime;
    }
    public void setEndTime(String endTime) {
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        LocalDateTime LocalTime = LocalDateTime.parse(endTime,df);
        this.endTime = LocalTime;
    }
//    public String getStartTime(LocalDateTime startTime){
//        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
//        String localTime = df.format(startTime);
//        return localTime;
//    }
//    public String getEndTime(LocalDateTime endTime){
//        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
//        String localTime = df.format(endTime);
//        return localTime;
//    }
}
